<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:include page="/WEB-INF/jsps/include/amazeUI.jsp" />

<div class="am-u-sm-12 am-u-md-10 am-u-lg-8 am-u-sm-centered">
	<form id="editForm" class="am-form">
		<div class="am-form-group">
			<label for="MenuName">菜单名称</label> <input type="text" value="${res.name }" name="name" id="MenuName" placeholder="输入菜单名称">
		</div>
	
		<div class="am-form-group">
			<label for="parentId">父ID</label> <input type="text" value="${res.parentId }" name="parentId" id="parentId" placeholder="输入父id">
		</div>
	
		<div class="am-form-group">
			<label for="permissionCode">权限码</label> <input type="text" value="${res.permission }" name="permission" id="permissionCode" placeholder="输入权限码">
		</div>
		
		<div class="am-form-group">
			<label for="ResTypeId">类型</label> 
			<select id="ResTypeId" name="type">
				<option value="menu" <c:if test="${res.type=='menu' }">selected</c:if>>菜单</option> 
				<option value="button" <c:if test="${res.type=='button' }">selected</c:if>>按钮</option>
			</select> <span class="am-form-caret"></span>
		</div>

		<div class="am-form-group">
			<label for="urlAddress">请求URL</label> <input type="text" value="${res.url }" name="url" id="urlAddress" placeholder="输入父id">
		</div>
	
		<div class="am-form-group">
			<label for="Icon">菜单图标</label> <input type="text" value="${res.icon }" name="icon" id="Icon" placeholder="输入父id">
		</div>
		
		<input type="hidden" value="${res.id }" name="id">
		
		<button type="button" class="am-btn am-btn-success" id="confirmBtnID" >确定</button>
		<button type="button" class="am-btn am-btn-danger" id="cancelBtnID">取消</button>
	</form>
	
</div>

<script type="text/javascript">
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
$(function(){
	cancelBtnClick();	//取消按钮点击事件
	confirmBtnClick();	//确定按钮点击事件
});
	
//点击取消按钮
function cancelBtnClick(){
	$("#cancelBtnID").click(function(){
		console.log("关窗");
		parent.layer.close(index);
	});
}
//确定按钮点击
function confirmBtnClick(){
	 $("#confirmBtnID").click(function(){
		console.log("确定");
		//do something...
		$.ajax({
			type:"post",
			url:"menuAddSubmit",
			data:$("#editForm").serialize(),
			success:function(data){
				console.log(data);
				//parent.location.reload();
				parent.$("#rightContent").load("menu/menuSet");
				parent.layer.close(index);
			}
		});
	});
}

</script>
